-
Notifications
You must be signed in to change notification settings - Fork 842
Add Zstandard compression support and update tests #12201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
[approve ci] |
|
@masaori335 do you know which files I need to modify to install zstd on the osx used in the Jenkins job? |
|
We need to ask @ezelkow1 to install the package in the osx env, I guess. However, this PR has |
0167bf5 to
74cd8b5
Compare
thank you, _F was a mistake, it was meant to be _H |
308032c to
c598282
Compare
|
Looks like all the FreeBSD machines for CI are offline |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really appreciate it if you can please add some documentation to the changes.
Thanks.
|
Hi! This doesn't compile for me. I added a line to Please include this patch in your PR to enable the ZSTD code. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please patch ink_config.h and resolve compiler issues.
4b8603e to
72c0dbf
Compare
# Conflicts: # contrib/docker/ubuntu/noble/Dockerfile # plugins/compress/configuration.cc # plugins/compress/configuration.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about the terrible delay getting back to this PR!
Autest is failing for me. Please change the 72 back to 7`` for the gzip gold tests.
More generally I don't think the autests will pass on systems without zstd. This is probably ok since it seems at least our autest images do have it.
| < Content-Encoding: gzip | ||
| < Vary: Accept-Encoding | ||
| < Content-Length: 7`` | ||
| < Content-Length: 72 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is causing autest to fail for me on my Mac.
|
I think the code is fine at this point, but I have a few concerns:
|
|
building without zstd enabled does compile, but the compress autest doesn't run: |
Comprehensive Testing Results for ZSTD Compression SupportI've completed comprehensive testing of PR #12201 across three test phases. All tests PASSED ✅ Test Environment
📊 Test Results SummaryTest 1: Baseline (Master Branch)Established baseline functionality with existing compression algorithms:
Test 2: PR #12201 WITHOUT ZSTD LibrariesVerified backward compatibility when ZSTD libraries are not available:
Result: No regressions. Existing compression algorithms continue to work when ZSTD is unavailable. Test 3: PR #12201 WITH ZSTD LibrariesVerified new ZSTD compression functionality:
Result: ZSTD compression works correctly and produces valid Zstandard compressed data. 🎯 Key Findings
📈 Compression Algorithm PerformanceOn the 4701-byte test file:
ZSTD achieves excellent compression, sitting between Brotli and GZIP in terms of compression ratio. ⚙️ Configuration RequirementsCritical: For Brotli and ZSTD to function properly, set: records:
http:
normalize_ae: 0Without this setting, ATS core normalizes the 🏗️ Build NotesThe PR's ZSTD detection via add_library(zstd::zstd UNKNOWN IMPORTED)
set_target_properties(zstd::zstd PROPERTIES
IMPORTED_LOCATION "/usr/lib64/libzstd.so"
INTERFACE_INCLUDE_DIRECTORIES "/usr/include"
)
set(zstd_FOUND TRUE)✅ ConclusionPR #12201 successfully implements ZSTD compression support without any regressions. The implementation:
All three test phases passed successfully. Great work on this feature! 🎉 |
Code Review - ZSTD Compression ImplementationThank you for this excellent work on adding ZSTD compression support! The testing shows the feature works well and achieves great compression ratios (98.6%). I've completed a thorough code review and found a few issues that should be addressed before merging. 🔴 Critical IssueResource Management in
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am ok with making the changes in this PR or create another PR, tests worked on my Fedora 42 server.
| libbrotli-dev \ | ||
| libzstd-dev \ | ||
| luajit \ | ||
| luajit \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should only be listed 1 time (luajit)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 88a02b2 (#12201)
| compression_algorithms_ |= ALGORITHM_DEFLATE; | ||
| } else { | ||
| error("Unknown compression type. Supported compression-algorithms <br,gzip,deflate>."); | ||
| error("Unknown compression type. Supported compression-algorithms <zstd,br,gzip,deflate>."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this error should be conditional based on how the plugin was compiled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 8e4f9c8 (#12201)
plugins/compress/compress.cc
Outdated
| } | ||
|
|
||
| static void | ||
| zstd_transform_init(Data *data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we know if the context is partially initialized? Seems like we should return a bool and check the return value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in e03fa5c (#12201)
plugins/compress/compress.cc
Outdated
| TSIOBufferBlock downstream_blkp; | ||
| int64_t downstream_length; | ||
|
|
||
| ZSTD_inBuffer input = {upstream_buffer, static_cast<size_t>(upstream_length), 0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No check to see if upstream_length is positive, can cause int overflow issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch! fixed in b87c864 (#12201)
plugins/compress/compress.cc
Outdated
| downstream_blkp = TSIOBufferStart(data->downstream_buffer); | ||
| char *downstream_buffer = TSIOBufferBlockWriteStart(downstream_blkp, &downstream_length); | ||
|
|
||
| ZSTD_outBuffer output = {downstream_buffer, static_cast<size_t>(downstream_length), 0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
downstream_length can be an int overflow here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
completed in 1b1ed1c (#12201)
|
I'll make the changes in this pr if that's okay 👍 |
Adjusts the condition for suppressing Vary header checks on Accept-Encoding to only apply when explicitly configured by the operator
This pull request adds full support for the zstd (Zstandard) compression algorithm throughout Apache Traffic Server, including build system integration, compression plugin support, Accept-Encoding header normalization, and test coverage.
Key Features
Build system and dependencies:
Findzstd.cmakelibzstd-devpackageTS_HAS_ZSTDfeature flag for conditional compilationCore compression support:
Accept-Encoding header normalization:
proxy.config.http.normalize_aeconfiguration to support values 4 and 5 for zstd normalizationAPI and infrastructure:
TS_HTTP_VALUE_ZSTDandTS_HTTP_LEN_ZSTDconstantsImproved cache matching:
Test Coverage
compress3.configfor zstd-specific plugin configurationStandards Compliance
The implementation follows RFC 8878 standards for zstd compression and maintains backward compatibility with existing gzip and brotli compression functionality. All tests pass and the feature is properly integrated with existing caching and content negotiation mechanisms.
Configuration
New normalization modes:
proxy.config.http.normalize_ae = 4: Prioritize zstd, fallback to br then gzipproxy.config.http.normalize_ae = 5: Support all combinations of zstd, br, and gzipBenefits